package com.dongni.faithtools;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.dongni.tools.Common;
import com.dongni.tools.DateUtils;

/**
 * 时间工具类测试
 * @autor hongbing
 * @date 2018/8/30
 */
public class DateUtilActivity extends AppCompatActivity implements View.OnClickListener {

    private static final String TAG = "DateUtilActivity";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dateutil_activity);
        findViewById(R.id.dateCurrDayStartBtn).setOnClickListener(this);
        findViewById(R.id.dateCurrDayEndBtn).setOnClickListener(this);
        findViewById(R.id.dateCurrWeekStartBtn).setOnClickListener(this);
        findViewById(R.id.dateCurrWeekEndBtn).setOnClickListener(this);
        findViewById(R.id.dateCurrMonthStartBtn).setOnClickListener(this);
        findViewById(R.id.dateCurrMonthEndBtn).setOnClickListener(this);
        findViewById(R.id.dateTimeZoneBtn).setOnClickListener(this);
    }

    /**
     * Called when a view has been clicked.
     *
     * @param v The view that was clicked.
     */
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.dateCurrDayStartBtn:
                Common.log_d(TAG, "当前日开始时间 = " + DateUtils.getDayStartTime());
                break;
            case R.id.dateCurrDayEndBtn:
                Common.log_d(TAG, "当前日结束时间 = " + DateUtils.getDayEndTime());
                break;
            case R.id.dateCurrWeekStartBtn:
                Common.log_d(TAG, "当前周开始时间 = " + DateUtils.getWeekStartTime());
                break;
            case R.id.dateCurrWeekEndBtn:
                Common.log_d(TAG, "当前周结束时间 = " + DateUtils.getWeekEndTime());
                break;
            case R.id.dateCurrMonthStartBtn:
                Common.log_d(TAG, "当前月开始时间 = " + DateUtils.getMonthStartTime());
                break;
            case R.id.dateCurrMonthEndBtn:
                Common.log_d(TAG, "当前月结束时间 = " + DateUtils.getMonthEndTime());
                break;
            case R.id.dateTimeZoneBtn:
                Common.log_d(TAG,
                        "系统默认时区时间戳 = " + DateUtils.getDayStartTime()
                                + "->系统当前时间戳 = " + System.currentTimeMillis()
                                + "->北时区day start = " + DateUtils.getDayStartTime()
                                + "->北时区day end = " + DateUtils.getDayEndTime()
                                + "->北时区week start = " + DateUtils.getWeekStartTime()
                                + "->北时区week end = " + DateUtils.getWeekEndTime()
                                + "->北时区month start = " + DateUtils.getMonthStartTime()
                                + "->北时区month end = " + DateUtils.getMonthEndTime()
                                + "->北时区year start = " + DateUtils.firstYearmilli(2019)
                                + "->北时区year end = " + DateUtils.lastYearmilli(2019)
                                + "->北时区stampToDateL = " + DateUtils.stampToDateL(System.currentTimeMillis())
                                + "->北时区stampToCurrChDayDate = " + DateUtils.stampToCurrChDayDate()
                                + "->北时区stampToDate = " + DateUtils.stampToDate(System.currentTimeMillis(), "yyyy-MM-dd HH:mm")
                                + "->北时区getFirstDayOfMonth = " + DateUtils.getFirstDayOfMonth("yyyy-MM-dd HH:mm")
                );
                break;
            default:
                break;
        }
    }
}
